package com.example.interviewrecorder.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.interviewrecorder.model.SecurityQuestion

@Dao
interface SecurityQuestionDao {

    @Insert
    fun insertSecurityQuestion(securityQuestion: SecurityQuestion)

    @Delete
    fun deleteSecurityQuestion(securityQuestion: SecurityQuestion)

    /**
     * 删除某个用户下的所有密保问题
     */
    @Query("delete from SecurityQuestion where userId = :userId")
    fun deleteAllSecurityQuestionById(userId:Long)

    @Update
    fun updateSecurityQuestion(securityQuestion: SecurityQuestion)

    @Query("select * from SecurityQuestion")
    fun queryAllSecurityQuestion(): List<SecurityQuestion>

    @Query("select * from SecurityQuestion where userId = :userId")
    fun querySQByUserId(userId: Long): List<SecurityQuestion>
}